package com.cn.action;




import org.apache.struts2.ServletActionContext;

import com.cn.dao.TaocanAddDao;
import com.cn.dao.TaocanDao;

import com.cn.entity.Taocan;
import com.cn.entity.Taocan_xiangmu;

import com.opensymphony.xwork2.Action;

public class TaocanAddAction implements Action {
	Taocan taocan;

	public Taocan getTaocan() {
		return taocan;
	}

	public void setTaocan(Taocan taocan) {
		this.taocan = taocan;
	}
	
	String xiangmuming;

	public String getXiangmuming() {
		return xiangmuming;
	}

	public void setXiangmuming(String xiangmuming) {
		this.xiangmuming = xiangmuming;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		
		String[] values = ServletActionContext.getRequest().getParameterValues("xiangmuming");
		
	           TaocanDao td=new TaocanDao();
	            td.add(taocan);
	        for (int i=0;i<values.length;i++){
	        	String id=values[i];
	        	int xiangmuid=Integer.parseInt(id);
	        	TaocanAddDao ta=new TaocanAddDao();
	        	Taocan_xiangmu tx=new Taocan_xiangmu(taocan.getTaocanid(),xiangmuid);
	        	ta.add(tx);
	        	
	        	
	        }
	            
	        	
	        
	        System.out.println("success");
		
		return "success";
	}
	
    
	
}
